import numpy as np

def check_pose(cord, flag):
    #0-4头部
    #5-6肩部
    #7-8手肘
    #9-10手
    #11-12臀部
    #13-14膝盖
    #15-16脚
    
    if flag == True:
        x1=cord[0,5,0]
        y1=cord[0,5,1]

        x2=cord[0,11,0]
        y2=cord[0,11,1]

        x3=cord[0,13,0]
        y3=cord[0,13,1]

        x4=cord[0,15,0]
        y4=cord[0,15,1]
    else:
        x1 = cord[0, 6, 0]
        y1 = cord[0, 6, 1]

        x2 = cord[0, 12, 0]
        y2 = cord[0, 12, 1]

        x3 = cord[0, 14, 0]
        y3 = cord[0, 14, 1]

        x4 = cord[0, 16, 0]
        y4 = cord[0, 16, 1]

    line1=[x2-x1, 3*(y2-y1)]
    line2=[x3-x2, 3*(y3-y2)]
    line3=[x4-x3, 3*(y4-y3)]

    cos1=cal_cos(line1,line2)
    cos2=cal_cos(line2,line3)
    
    return [cos1,cos2]

def cal_cos(line1,line2):
    cos=(line1[1]*line2[1]+line1[0]*line2[0])/(np.sqrt(np.power(line1[0],2)+np.power(line1[1],2))*np.sqrt(np.power(line2[0],2)+np.power(line2[1],2))+0.00001)
    return cos